﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using LongNet.Model.pcl;
using LongNet.Util;
namespace LongNet.Web.Controllers
{
    public class ActiveController : Controller
    {
        //
        // GET: /Active/

        public ActionResult Index()
        {
            List<ActivityGoods> m_actives = LongNet.Bussiness.pcl.ActivityGoodsB.GetModels("").ToList();
         
           return View(m_actives);
        }

        //
        // GET: /Active/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /Active/Create

        public ActionResult Create()
        {
            ActivityGoods m_active = new ActivityGoods();
            m_active.MailTitle = "测试增加";
            m_active.MailContent = "测试增加";
            Result rs = LongNet.Bussiness.pcl.ActivityGoodsB.Add(m_active);
            return Content("Create " + rs.IsSuccess + rs.Msg);
        } 

        //
        // POST: /Active/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        
        //
        // GET: /Active/Edit/5
 
        public ActionResult Edit()
        {
            List<ActivityGoods> m_actives = LongNet.Bussiness.pcl.ActivityGoodsB.GetModels("").ToList();
            m_actives[0].MailContent = "测试修改";
            Result rs = LongNet.Bussiness.pcl.ActivityGoodsB.Update(m_actives[0]);
            return Content("Edit " + rs.IsSuccess + rs.Msg);
        }

        //
        // POST: /Active/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Active/Delete/5
 
        public ActionResult Delete()
        {
            List<ActivityGoods> m_actives = LongNet.Bussiness.pcl.ActivityGoodsB.GetModels("").ToList();
           Result rs= LongNet.Bussiness.pcl.ActivityGoodsB.Delete(m_actives[0].Id);
            return Content("Delete "+rs.IsSuccess+rs.Msg);
        }

        //
        // POST: /Active/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
